<!--课程成绩单打印-->
<template>
  <div class="assessment-container" style="width:100%">
    <div class="search-container" style="margin:0;padding-left:0">
      <div class="search-container-left">
        <div class="search-container-item">
          <span>学期：</span>
          <el-select
            v-model="xq"
            style="width: 90px"
            size="mini"
            placeholder="请选择"
            clearable
          >
          <!-- @clear="clickSearch" -->
            <el-option
              v-for="item in xqList"
              :key="item.value"
              :label="item.xqmc"
              :value="item.xqmc"
            >
            </el-option>
          </el-select>
        </div>
        <div class="search-container-item">
          <span>课程负责单位：</span>
          <el-select
            v-model="xb"
            style="width: 88px;margin-right:5px"
            size="mini"
            placeholder="请选择"
            @change="handleXb"
            clearable
          >
            <el-option
             style="margin-right:5px"
              v-for="(item,index) in xbList"
              :key="index"
              :label="item.deptName"
              :value="item.deptName"
            >
            </el-option>
          </el-select>
          <el-select
            v-model="gClass"
            style="width: 88px"
            size="mini"
            placeholder="请选择"
            @change="handleClass"
            clearable
            
          >
            <el-option
              v-for="(item,index) in gClassList"
              :key="index"
              :label="item.deptName ? item.deptName : item.value"
              :value="item.deptName ? item.deptName : item.value"
            >
            </el-option>
          </el-select>
        </div>
        <div class="search-container-item">
          <span>课程编号：</span>
          <el-input
            style="width: 152px"
            size="mini"
            placeholder="请输入内容"
            v-model="coursenumber"
            clearable
          ></el-input>
        </div>
        <div class="search-container-item">
          <span>课程名称：</span>
          <el-input
            style="width: 152px"
            size="mini"
            placeholder="请输入内容"
            v-model="coursename"
            clearable
          ></el-input>
        </div>
        <!-- <el-button type="primary" size="mini" icon="el-icon-search" @click="clickSearch">查 询</el-button> -->
        <div class="search-button" style="margin:2px 0 0 0" @click="clickSearch">
          <img src="../../../assets/assessment/icon-search.png" alt="" />
          <span>查询</span>
        </div>
      </div>
      <div class="search-container-right">
        <!-- <el-button type="primary" size="mini" icon="el-icon-document" @click="toMakeupScoreEntry" style="margin-left:10px">补 考</el-button>
        <el-button type="primary" size="mini" icon="el-icon-document" @click="toMakeupScoreEntry">第二次补考</el-button> -->
        <div class="search-button" @click="toMakeupScoreEntry('one')" style="margin:2px 15px 0 0">
          <img src="../../../assets/assessment/icon-search.png" alt="" />
          <span>补考</span>
        </div>
        <div class="search-button" @click="toMakeupScoreEntry('two')" style="width:120px;margin:2px 0 0 0">
          <img src="../../../assets/assessment/icon-search.png" alt="" />
          <span>第二次补考</span>
        </div>
        <div class="export-button" style="width: 150px;margin: 0 0 10px 15px;" @click="clickAllExcel">
          <img src="../../../assets/assessment/icon-export.png" alt="" />
          <span>分项成绩导出</span>
        </div>
        <div class="export-button" style="width: 150px;margin: 0 0 10px 15px;" @click="clickAllExcelZ">
          <img src="../../../assets/assessment/icon-export.png" alt="" />
          <span>总评成绩导出</span>
        </div>
      </div>
    </div>
    <div class="plan-entry-table-container">
      <el-table
        :data="tableData"
        style="width: 100%"
        class="xpaas-table-class"
        row-class-name="xpaas-row-class"
        cell-class-name="xpaas-cell-class"
        header-row-class-name="xpaas-header-row-class"
        header-cell-class-name="xpaas-header-cell-class"
        @selection-change="handleSelection"
      >
        <el-table-column width="70" align="center" type="selection">
        </el-table-column>
        <el-table-column
          prop="lrcj"
          label="分项成绩导出"
          width="134"
          align="center"
          class-name=""
          label-class-name=""
        >
          <template slot-scope="scope">
            <!-- <el-button type="warning" size="mini" icon="el-icon-download" @click="downScore(scope.$index)">打印</el-button>
            <el-button type="success" size="mini" icon="el-icon-view" @click="details(scope.row)" style="margin:5px 0 0 0">预览</el-button> -->
            <div class="export-button" style="width: 81px;margin: 0 0 10px 15px;" @click="downScore(scope.$index)">
              <img src="../../../assets/assessment/icon-export.png" alt="" />
              <span>打印</span>
            </div>
            <div
              class="lucj-import-button" style="width: 81px;font-size:14px"
              @click="details('分项',scope.row)"
            >
              <img src="../../../assets/assessment/icon-plan-record-detail.png" alt="" />
              <span>预览</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column
          prop="dccjd"
          label="总评成绩导出"
          width="134"
          align="center"
        >
          <template slot-scope="scope">
            <!-- <el-button type="warning" size="mini" icon="el-icon-download" @click="savezong(scope.$index)">打印</el-button>
            <el-button type="success" size="mini" icon="el-icon-view" @click="details(scope.row)" style="margin:5px 0 0 0">预览</el-button> -->
            <div class="export-button" style="width: 81px;margin: 0 0 10px 15px;" @click="savezong(scope.$index)">
              <img src="../../../assets/assessment/icon-export.png" alt="" />
              <span>打印</span>
            </div>
            <div
              class="lucj-import-button" style="width: 81px;"
              @click="details('总评',scope.row)"
            >
              <img src="../../../assets/assessment/icon-plan-record-detail.png" alt="" />
              <span>预览</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="termid" label="学期" align="center" width="120px">
        </el-table-column>
        <el-table-column prop="coursenumber" label="课程编号" align="center">
        </el-table-column>
        <el-table-column prop="coursename"  label="课程名称" align="center" width="200px"> 
          <template slot-scope="scope">
            <button class="clickName" @click="details('详情',scope.row)">
              <!-- <img src="../../../assets/assessment//引用(1).png" /> -->
              {{scope.row.coursename}}
            </button>
          </template> 
        </el-table-column>
        <el-table-column prop="studytype" label="修习类型" align="center">
        </el-table-column>
        <el-table-column prop="department" label="系" align="center">
        </el-table-column>
        <el-table-column prop="teachingandresearchsection" label="教研室" align="center"
        >
        </el-table-column>
        <el-table-column prop="grade" label="年级" align="center">
        </el-table-column>
        <el-table-column prop="professionaldivisions" label="专业班次" align="center">
          <template slot-scope="scope">
            {{scope.row.professionaldivisions}}
          </template> 
        </el-table-column>
      </el-table>
      <div class="block" style="margin-bottom: 50px;">
        <el-pagination
          style="width:auto;margin-top: 15px;float:right;margin-bottom:50px;padding:0"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="pageNo"
          :page-sizes="[5, 10, 20, 30,50,100,200]"
          :page-size="5"
          layout="total, sizes, prev, pager, next, jumper"
          :total="tableData.length > 0 ? tableData[0].tol : ''"
        >
        </el-pagination>
      </div>
    </div>
    <el-dialog
      title="导出分项成绩单"
      :visible.sync="showExportReportDialogags"
      width="1185px"
      class="manual-entry-containerass"
    >
      <div class="my-form-container" style="width: 100%; height: 291px">
        <el-row>
          <el-col :span="16">
            <div>成绩范围</div>
            <div>
              <el-radio-group v-model="reportTypep">
                <el-radio
                  :label="item.label"
                  v-for="(item, index) in reportTypepss"
                  :key="index"
                  class="large"
                  >{{ item.value }}</el-radio
                >
              </el-radio-group>
            </div>
          </el-col>
        </el-row>
        <el-row style="width: 100%">
          <el-col :span="16">
            <div>成绩类型</div>
            <div>
              <el-radio-group v-model="reportType">
                <el-radio
                  :label="item.label"
                  v-for="(item, index) in reportTypes"
                  :key="index"
                  class="large"
                  >{{ item.value }}</el-radio
                >
              </el-radio-group>
            </div>
          </el-col>
        </el-row>
        <el-row style="width: 100%">
          <el-col :span="16">
            <div>文件类型</div>
            <div>
              <el-radio-group v-model="fileType">
                <el-radio
                  :label="item.label"
                  v-for="(item, index) in fileTypes"
                  :key="index"
                  class="large"
                  >{{ item.value }}</el-radio
                >
              </el-radio-group>
            </div>
          </el-col>
        </el-row>
      </div>
      <div style="margin: 30px auto;width: 100px;border:none">
        <span slot="footer" class="dialog-footer">
          <button @click="savefx">保存</button>
        </span>
      </div>
    </el-dialog>
    <el-dialog
      title="导出总评成绩单"
      :visible.sync="showExportReportDialog"
      width="1185px"
      class="manual-entry-containerass"
    >
      <div class="my-form-container" style="width: 100%; height: 192px">
        <el-row>
          <el-col :span="16">
            <div>成绩范围</div>
            <div>
              <el-radio-group v-model="reportTypep">
                <el-radio
                  :label="item.label"
                  v-for="(item, index) in reportTypepss"
                  :key="index"
                  class="large"
                  >{{ item.value }}</el-radio
                >
              </el-radio-group>
            </div>
          </el-col>
        </el-row>
        <el-row style="width: 100%">
          <el-col :span="16">
            <div>文件类型</div>
            <div>
              <el-radio-group v-model="fileType">
                <el-radio
                  :label="item.label"
                  v-for="(item, index) in fileTypes"
                  :key="index"
                  class="large"
                  >{{ item.value }}</el-radio
                >
              </el-radio-group>
            </div>
          </el-col>
        </el-row>
      </div>
      <div style="margin: 30px auto;width: 100px;border:none">
        <span slot="footer" class="dialog-footer">
          <button @click="saveover">保 存</button>
        </span>
      </div>
    </el-dialog>
    <!-- 批量导出分项成绩单PDF -->
    <el-dialog
      title="导出分项成绩单"
      :visible.sync="showAllReportDialog"
      width="1185px"
      class="manual-entry-containerass"
    >
      <div class="my-form-container" style="width: 100%; height: 192px">
        <el-row>
          <el-col :span="16">
            <div>成绩范围</div>
            <div>
              <el-radio-group v-model="reportTypep">
                <el-radio
                  :label="item.label"
                  v-for="(item, index) in reportTypepss"
                  :key="index"
                  class="large"
                  >{{ item.value }}</el-radio
                >
              </el-radio-group>
            </div>
          </el-col>
        </el-row>
        <el-row style="width: 100%">
          <el-col :span="16">
            <div>成绩类型</div>
            <div>
              <el-radio-group v-model="reportType">
                <el-radio
                  :label="item.label"
                  v-for="(item, index) in reportTypes"
                  :key="index"
                  class="large"
                  >{{ item.value }}</el-radio
                >
              </el-radio-group>
            </div>
          </el-col>
        </el-row>
      </div>
      <div style="margin: 30px auto;width: 100px;border:none">
        <span slot="footer" class="dialog-footer">
          <button @click="saveoverAll">保 存</button>
        </span>
      </div>
    </el-dialog>
    <!-- 批量导出总评成绩单PDF -->
    <el-dialog
      title="导出总评成绩单"
      :visible.sync="showAllReportDialogZ"
      width="1185px"
      class="manual-entry-containerass"
    >
      <div class="my-form-container" style="width: 100%; height: 96px">
        <el-row>
          <el-col :span="16">
            <div>成绩范围</div>
            <div>
              <el-radio-group v-model="reportTypep">
                <el-radio
                  :label="item.label"
                  v-for="(item, index) in reportTypepss"
                  :key="index"
                  class="large"
                  >{{ item.value }}</el-radio
                >
              </el-radio-group>
            </div>
          </el-col>
        </el-row>
      </div>
      <div style="margin: 30px auto;width: 100px;border:none">
        <span slot="footer" class="dialog-footer">
          <button @click="saveoverAllZ">保 存</button>
        </span>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { reqGetXqList } from "@/api/admin1/check";
import { getxb,getClass,queryXBclassroom,transcriptPrint,outoverFxrating,outoverallrating,outoverFxratingforpdf,outoverallratingforpdf,reqeditById } from "@/api/course/courses";
export default {
  data() {
    return {
      pageNo:1,
      pageSize:5,
      xq: "",
      xb:'',
      gClass:'',
      coursename: "",
      coursenumber:"",
      xqList: [],
      xbList:[],
      gClassList:[],
      tableData: [],
      showExportReportDialog: false,
      showExportReportDialogags: false,
      showAllReportDialog:false,
      showAllReportDialogZ:false,
      reportTypep: "按教学班导出",
      reportTypepss: [
        { label: "按教学班导出", value: "按教学班导出" },
        { label: "按课程导出", value: "按课程导出" },
      ],
      reportType: "课下作业",
      reportTypes: [
        { label: "课下作业", value: "课下作业" },
        { label: "课下测评", value: "课下测评" },
        { label: "期中考试", value: "期中考试" },
        { label: "课终考核", value: "课终考核" },
      ],
      fileType: "Word",
      fileTypes: [
        { label: "Word", value: "Word" },
        { label: "PDF", value: "PDF" }
      ],
      handleSelectionData:[]
    };
  },
  mounted() {
    this.termAll();
    this.xbAll();
    this.classAll();
    this.clickSearch();
  },
  methods: {
    handleSelection(val){
      this.handleSelectionData = val;
    },
    handleCurrentChange(val) {
      this.pageNo = val;
      this.clickSearch();
    },
    handleSizeChange(val) {
      this.pageSize = val;
      this.clickSearch();
    },
    async termAll(){
      const result = await reqGetXqList();
      result.data.code == 200 ? this.xqList = result.data.data : [];
    },
    async xbAll(){
      const xb = await getxb();
      xb.data.code == 200 ? this.xbList = xb.data.data : [];
    },
    async classAll(){
      const gClass = await getClass();
      gClass.data.code == 200 ? this.gClassList = gClass.data.data : [];
    },
    // 教研室下拉框的改变
    handleClass(val){
      if(!val){
        this.xb ? this.handleXb(this.xb)  : this.classAll();
      }
    },
    // 根据系部选中获取教研室
    async handleXb(val){
      if(val){
        const xbClass = await queryXBclassroom(val);
        xbClass.data.code == 200 ? this.gClassList = xbClass.data.data : [];
        this.gClass = ''
      } else {
        this.xbAll();
        this.classAll();
      }
    },
    //查询
    clickSearch(){
      let obj = {
        termid:this.xq,
        department:this.xb,
        teachingandresearchsection:this.gClass,
        coursenumber:this.coursenumber,
        coursename:this.coursename,
        pageNo:this.pageNo,
        pageSize:this.pageSize
      }
      return new Promise(() => {
        transcriptPrint(obj).then((res) => {
          this.tableData = res.data.data;
          // this.pageNo = 1
        });
      });
    },
    // 教研室下拉框的改变
    handleClass(val){
      if(!val){
        this.xb ? this.handleXb(this.xb)  : this.classAll();
      }
    },
    //表格分项成绩点击
    downScore(index) {
      this.showExportReportDialogags = true;
      this.reportIndex = index;
    },
    savefx() {
      // let el = this;
      let fx = this.reportType; //成绩类型
      if (this.reportTypep == "按教学班导出" && this.fileType == 'Word') {
        let classesid1 = this.tableData[this.reportIndex].classesid;
        let planid1 = '';
        outoverFxrating(classesid1,fx,planid1).then(res=>{
          if(res.data.data) {
            this.$message({ type: "error", message: res.data.data });
            this.showExportReportDialogags = true;
            this.showExportReportDialog = false;
          } else {
            this.showExportReportDialogags = false;
            this.showExportReportDialog = false;
            const blob = new Blob([res.data]);
            let url = URL.createObjectURL(blob);
            /** 模拟浏览器操作Document，并模拟下载动作 */
            let link = document.createElement("a");
            link.style.display = "none";
            link.href = url;
            link.setAttribute("download", "按教学班导出分项成绩单.doc");
            document.body.appendChild(link);
            link.click();
          }
        })
      } else if (this.reportTypep == "按课程导出" && this.fileType == 'Word'){
        let planid1 = this.tableData[this.reportIndex].planid;
        let classesid1 = '';
        outoverFxrating(classesid1,fx,planid1).then(res=>{
          if(res.data.data) {
            this.$message({ type: "error", message: res.data.data });
            this.showExportReportDialogags = true;
            this.showExportReportDialog = false;
          } else {
            this.showExportReportDialogags = false;
            this.showExportReportDialog = false;
            const blob = new Blob([res.data]);
            let url = URL.createObjectURL(blob);
            /** 模拟浏览器操作Document，并模拟下载动作 */
            let link = document.createElement("a");
            link.style.display = "none";
            link.href = url;
            link.setAttribute("download", "按课程导出分项成绩单.doc");
            document.body.appendChild(link);
            link.click();
          }
        })
      } else if(this.reportTypep == "按教学班导出" && this.fileType == 'PDF'){
        let classesid1 = this.tableData[this.reportIndex].classesid;
        let planid1 = '';
        outoverFxratingforpdf(classesid1,fx,planid1).then(res=>{
          // if("success" === res.data.data.code) {
          //   this.showExportReportDialogags = false;
          //   this.showExportReportDialog = false;
          //   const downloadURL = window.location.origin + `/api/xpaas-course-service/testscorequery/outoverFxratingforpdf?classid1=${classesid1}&fx=${fx}&planid1=${planid1}`;
          //   window.open(downloadURL, '_blank'); 
          // } else {
          //   this.$message({ type: "error", message: res.data.data.msg });
          //   this.showExportReportDialogags = true;
          //   this.showExportReportDialog = false;
          // }
          if(res.data.data) {
            this.$message({ type: "error", message: res.data.data });
            this.showExportReportDialogags = true;
            this.showExportReportDialog = false;
          } else {
            this.showExportReportDialogags = false;
            this.showExportReportDialog = false;
            const blob = new Blob([res.data]);
            let url = URL.createObjectURL(blob);
            /** 模拟浏览器操作Document，并模拟下载动作 */
            let link = document.createElement("a");
            link.style.display = "none";
            link.href = url;
            link.setAttribute("download", "按教学班导出分项成绩单.PDF");
            document.body.appendChild(link);
            link.click();
          }
        })
      } else if(this.reportTypep == "按课程导出" && this.fileType == 'PDF'){
        let planid1 = this.tableData[this.reportIndex].planid;
        let classesid1 = '';
        outoverFxratingforpdf(classesid1,fx,planid1).then(res=>{
          if(res.data.data) {
            this.$message({ type: "error", message: res.data.data });
            this.showExportReportDialogags = true;
            this.showExportReportDialog = false;
          } else {
            this.showExportReportDialogags = false;
            this.showExportReportDialog = false;
            const blob = new Blob([res.data]);
            let url = URL.createObjectURL(blob);
            /** 模拟浏览器操作Document，并模拟下载动作 */
            let link = document.createElement("a");
            link.style.display = "none";
            link.href = url;
            link.setAttribute("download", "按课程导出分项成绩单.PDF");
            document.body.appendChild(link);
            link.click();
          }
        })
      }
    },
    //表格总评成绩点击
    savezong(index) {
      this.showExportReportDialog = true;
      this.reportIndex = index;
    },
    //总评成绩单打印
    saveover() {
      // let el = this;
      let fx = this.reportType; //成绩类型:
      if (this.reportTypep == "按教学班导出" && this.fileType == 'Word') {
        let classesid1 = this.tableData[this.reportIndex].classesid;
        let planid1 = '';
        outoverallrating(classesid1,planid1).then(res=>{
          if(res.data.type == 'application/json') {
            this.$message({ type: "error", message: '所选课程含未审核完成的成绩' });
            this.showExportReportDialogags = false;
            this.showExportReportDialog = true;
          } else {
            this.showExportReportDialogags = false;
            this.showExportReportDialog = false;
            const blob = new Blob([res.data]);
            let url = URL.createObjectURL(blob);
            /** 模拟浏览器操作Document，并模拟下载动作 */
            let link = document.createElement("a");
            link.style.display = "none";
            link.href = url;
            link.setAttribute("download", "按教学班导出总评成绩单.zip");
            document.body.appendChild(link);
            link.click();
          }
        })
      } else if (this.reportTypep == "按课程导出" && this.fileType == 'Word'){
        let planid1 = this.tableData[this.reportIndex].planid;
        let classesid1 = '';
        outoverallrating(classesid1,planid1).then(res=>{
          if(res.data.type == 'application/json') {
            this.$message({ type: "error", message: '所选课程含未审核完成的成绩' });
            this.showExportReportDialogags = false;
            this.showExportReportDialog = true;
          } else {
            this.showExportReportDialogags = false;
            this.showExportReportDialog = false;
            const blob = new Blob([res.data]);
            let url = URL.createObjectURL(blob);
            /** 模拟浏览器操作Document，并模拟下载动作 */
            let link = document.createElement("a");
            link.style.display = "none";
            link.href = url;
            link.setAttribute("download", "按课程导出总评成绩单.zip");
            document.body.appendChild(link);
            link.click();
          }
        })
      } else if(this.reportTypep == "按教学班导出" && this.fileType == 'PDF'){
        let classesid1 = this.tableData[this.reportIndex].classesid;
        let planid1 = '';
        outoverallratingforpdf(classesid1,planid1).then(res=>{
          if(res.data.type == 'application/json') {
            this.$message({ type: "error", message: '所选课程含未审核完成的成绩' });
            this.showExportReportDialogags = false;
            this.showExportReportDialog = true;
          } else {
            this.showExportReportDialogags = false;
            this.showExportReportDialog = false;
            const blob = new Blob([res.data]);
            let url = URL.createObjectURL(blob);
            /** 模拟浏览器操作Document，并模拟下载动作 */
            let link = document.createElement("a");
            link.style.display = "none";
            link.href = url;
            link.setAttribute("download", "按教学班导出总评成绩单.zip");
            document.body.appendChild(link);
            link.click();
          }
        })
      } else if(this.reportTypep == "按课程导出" && this.fileType == 'PDF'){
        let planid1 = this.tableData[this.reportIndex].planid;
        let classesid1 = '';
        outoverallratingforpdf(classesid1,planid1).then(res=>{
          if(res.data.type == 'application/json') {
            this.$message({ type: "error", message: '所选课程含未审核完成的成绩' });
            this.showExportReportDialogags = false;
            this.showExportReportDialog = true;
          } else {
            this.showExportReportDialogags = false;
            this.showExportReportDialog = false;
            const blob = new Blob([res.data]);
            let url = URL.createObjectURL(blob);
            /** 模拟浏览器操作Document，并模拟下载动作 */
            let link = document.createElement("a");
            link.style.display = "none";
            link.href = url;
            link.setAttribute("download", "按课程导出总评成绩单.zip");
            document.body.appendChild(link);
            link.click();
          } 
        })
      }
    },
    details(type,row){
      reqeditById(row.classesid).then(res=>{
        let data = res.data.data;
        if(res.data.code == 200 && data.kxzystate == '3' && data.ktcpstate == '3' && data.qzksstate == '3' && data.kzkhstate == '3' && data.oldstate == '3' && data.oldstate2 == '3'){
          localStorage.setItem('studentData',JSON.stringify(data));
          localStorage.setItem('routeoneSign','transPage');
          if(type == '分项'){
            this.$router.push({
              path: "/admin/courseAssessment/requditByInfo", //要跳转的页面的路由
            });
          } else if(type == '总评'){
            this.$router.push({
              path: "/admin/courseAssessment/requditByInfoF", //要跳转的页面的路由
            });
          } else {
            this.$router.push({
              path: "/admin/courseAssessment/requditByInfoC", //要跳转的页面的路由
            });
          }
        } else {
          this.$message({ type: "error", message: '该课程成绩还在审核中！' });
        }
      })
    },
    toMakeupScoreEntry(type) {
      if(type == 'one'){
        this.$router.push({
          path: "/admin/courseAssessment/examTranscript",
          query:{type}
        });
      } else if(type == 'two'){
        this.$router.push({
          path: "/admin/courseAssessment/examTranscriptTwo",
          query:{type}
        });
      }
    },
    //分项批量打印弹框
    clickAllExcel(){
      if(this.handleSelectionData.length > 0){
        this.showAllReportDialog = true;
      } else {
        this.$message({ type: "error", message: '请选择需要导出的数据！' });
        return
      }
    },
    //分项批量打印PDF
    saveoverAll(){
      let fx = this.reportType; //成绩类型
      let classid1 = '',planid1 = '';
      let newclassId = '';
      let newplanId = '';
      this.handleSelectionData.forEach(item=>{
        classid1 += item.classesid + ',';
        planid1 += item.planid + ',';
        newclassId = classid1.substring(0,classid1.length - 1);
        newplanId = planid1.substring(0,planid1.length - 1);
      })
      if(this.reportTypep == '按教学班导出'){
        outoverFxratingforpdf(newclassId,fx,'').then(res=>{
          // if("success" === res.data.data.code) {
          //   const downloadURL = window.location.origin + `/api/xpaas-course-service/testscorequery/outoverFxratingforpdf?classid1=${newclassId}&fx=${fx}&planid1=${''}`;
          //   window.open(downloadURL, '_blank'); 
          // } else {
          //   this.$message({ type: "error", message: '未审核完成的成绩不能进行导出！' });
          //   return 
          // }
          if(res.data.data) {
            this.$message({ type: "error", message: res.data.data });
          } else {
            const blob = new Blob([res.data]);
            let url = URL.createObjectURL(blob);
            /** 模拟浏览器操作Document，并模拟下载动作 */
            let link = document.createElement("a");
            link.style.display = "none";
            link.href = url;
            link.setAttribute("download", "按教学班导出总评成绩单.PDF");
            document.body.appendChild(link);
            link.click();
          }
        })
      } else {
        outoverFxratingforpdf('',fx,newplanId).then(res=>{
          if(res.data.data) {
            this.$message({ type: "error", message: res.data.data });
          } else {
            const blob = new Blob([res.data]);
            let url = URL.createObjectURL(blob);
            /** 模拟浏览器操作Document，并模拟下载动作 */
            let link = document.createElement("a");
            link.style.display = "none";
            link.href = url;
            link.setAttribute("download", "按课程导出总评成绩单.PDF");
            document.body.appendChild(link);
            link.click();
          }
          // if("success" === res.data.data.code) {
          //   const downloadURL = window.location.origin + `/api/xpaas-course-service/testscorequery/outoverFxratingforpdf?classid1=${''}&fx=${fx}&planid1=${newplanId}`;
          //   window.open(downloadURL, '_blank'); 
          // } else {
          //   this.$message({ type: "error", message: '未审核完成的成绩不能进行导出！' });
          //   return 
          // }
        })
      }
    },
    //总评批量打印
    clickAllExcelZ(){
      if(this.handleSelectionData.length > 0){
        this.showAllReportDialogZ = true;
      } else {
        this.$message({ type: "error", message: '请选择需要导出的数据！' });
        return
      }
    },
    //总评批量打印PDF
    saveoverAllZ(){
      let classid1 = '',planid1 = '';
      let newclassId = '';
      let newplanId = '';
      this.handleSelectionData.forEach(item=>{
        classid1 += item.classesid + ',';
        planid1 += item.planid + ',';
        newclassId = classid1.substring(0,classid1.length - 1);
        newplanId = planid1.substring(0,planid1.length - 1);
      })
      if(this.reportTypep == '按教学班导出'){
        outoverallratingforpdf(newclassId,'').then(res=>{
          if(res.data.type == 'application/json') {
            this.$message({ type: "error", message: '所选课程含未审核完成的成绩' });
          } else {
            this.showExportReportDialogags = false;
            this.showExportReportDialog = false;
            const blob = new Blob([res.data]);
            let url = URL.createObjectURL(blob);
            /** 模拟浏览器操作Document，并模拟下载动作 */
            let link = document.createElement("a");
            link.style.display = "none";
            link.href = url;
            link.setAttribute("download", "按课程导出总评成绩单.zip");
            document.body.appendChild(link);
            link.click();
          }
        })
      } else {
        outoverallratingforpdf('',newplanId).then(res=>{
          if(res.data.type == 'application/json') {
            this.$message({ type: "error", message: '所选课程含未审核完成的成绩' });
          } else {
            this.showExportReportDialogags = false;
            this.showExportReportDialog = false;
            const blob = new Blob([res.data]);
            let url = URL.createObjectURL(blob);
            /** 模拟浏览器操作Document，并模拟下载动作 */
            let link = document.createElement("a");
            link.style.display = "none";
            link.href = url;
            link.setAttribute("download", "按课程导出总评成绩单.zip");
            document.body.appendChild(link);
            link.click();
          }
        })
      }
    },
  },
};
</script>
<style lang="less" scoped>
.assessment-container {
  .export-report-container {
    .el-dialog__body {
      padding: 64px 0 64px 50px;
      .el-radio {
        margin-right: 79px;
      }
    }
    .el-dialog__footer {
      padding-bottom: 103px;
    }
  }
  .import-report-container {
    .el-dialog__body {
      padding-left: 165px;
      padding-top: 71px;
      padding-bottom: 60px;
      > div {
        > span {
          font-size: 18px;
          font-weight: bold;
          line-height: 20px;
          color: #004ca7;
          vertical-align: middle;
        }
        > input {
          width: 254px;
          height: 25px;
          border: 1px solid #004ca7;
          opacity: 1;
          border-radius: 4px;
          padding-left: 5px;
          margin-right: 8px;
          color: #004ca7;
          vertical-align: middle;
        }
        > div {
          display: inline-block;
          font-size: 18px;
          padding: 1px 10px;
          border-radius: 4px;
          vertical-align: middle;
          cursor: pointer;
          &:nth-child(3) {
            color: rgba(2, 200, 108, 1);
            background: #f1fff8;
            border: 1px solid #02c86c;
            position: relative;
            margin-right: 20px;
            > input {
              width: 0px;
              position: absolute;
              left: 0;
              opacity: 1;
              cursor: pointer;
            }
          }
          &:nth-child(4) {
            color: rgba(82, 48, 233, 1);
            background: rgba(235, 230, 255, 1);
            border: 1px solid rgba(82, 48, 233, 1);
          }
        }
      }
    }
    .el-dialog__footer {
      padding-bottom: 76px;
      .green {
        padding: 1px 17px;
      }
    }
  }
}
.plan-entry-table-container {
  margin-top: 15px;
  .el-table td,
  .el-table th.is-leaf,
  .el-table--border,
  .el-table--group {
    border-color: #c7d7eb;
  }
  .el-table__header tr,
  .el-table__header th {
    padding: 0;
    height: 76px;
    background-color: #edf2f9;
    font-size: 16px;
    font-family: Microsoft YaHei;
    font-weight: bold;
    line-height: 20px;
    color: #004ca7;
  }
  .el-table__body tr,
  .el-table__body td {
    padding: 0;
    height: 86px;
  }
  .el-checkbox__inner:hover {
    border-color: #004ca7;
  }
  .el-checkbox__inner {
    border: 1px solid #004ca7;
    border-radius: 0;
  }
  .el-checkbox__input.is-checked .el-checkbox__inner,
  .el-checkbox__input.is-indeterminate .el-checkbox__inner {
    background-color: #004ca7;
    border-color: #004ca7;
  }
  .el-checkbox__input.is-checked + .el-checkbox__label {
    color: #004ca7;
  }
  .el-checkbox.is-bordered.is-checked {
    border-color: #004ca7;
  }
  .el-checkbox__input.is-focus .el-checkbox__inner {
    border-color: #004ca7;
  }
  .export-button {
    background: #fff6ef;
    border: 1px solid #f3b815;
    width: auto;
    height: 28px;
    line-height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    padding: 3px 10px;
    box-sizing: border-box;
    > span {
      font-size: 16px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: #f3b815;
    }
    > img {
      width: 16px;
      height: 16px;
      margin-right: 5px;
    }
  }

  .lucj-import-button {
    .export-button;
    width: 116px;
    margin: 0 auto 12px;
    background: #f1fff8;
    border: 1px solid #02c86c;
    &:last-child {
      margin-bottom: 0px;
    }
    > span {
      color: #02c86c;
    }
  }
  .lucj-expot-button {
    .export-button;
    background: #fff6ef;
    border: 1px solid #f3b815;
    width: 81px;
    margin: 0 auto 12px;
    &:last-child {
      margin-bottom: 0px;
    }
    > span {
      color: #f3b815;
    }
  }
}
</style>
<style lang="less" scoped>
@import "../../../styles/print-entry.less";

.manual-entry-containerass {
  .el-dialog__body {
    > div {
      width: 1014px;
      border: 1px solid rgba(0, 76, 167, 0.8);
      border-radius: 6px;
      margin: 0 auto;
      > div {
        border-bottom: 1px solid rgba(0, 76, 167, 0.39);
        &:last-child {
          border-bottom: none;
        }
        > div {
          display: flex;
          > div {
            width: 900px;
            height: 96px;
            display: flex;
            align-items: center;
            justify-content: center;
            &:nth-child(1) {
              width: 420px;
              text-align: center;
              font-size: 16px;
              font-weight: bold;
              color: #004ca7;
              background: rgba(77, 129, 192, 0.1);
            }
            &:nth-child(2) {
              padding-left: 19px;
            }
          }
        }
      }
    }
  }
  .el-dialog__footer {
    padding-bottom: 43px;
  }
  .dialog-footer {
    > button {
      width: 87px;
      height: 36px;
      background: #fff6ef;
      border: 1px solid #f3b815;
      border-radius: 6px;
      background: rgba(255, 246, 239, 1);
      font-size: 18px;
      color: #f3b815;
    }
  }
}
.clickName {
    height: 27px;
    background: none;
    opacity: 1;
    color: #004ca7;
    padding: 5px 5px;
    line-height: 5px;
    border: none;
}
.plan-entry-table-container {
  margin-top: 15px;
  .table-data {
    width: 100%;
    border: 0.8px solid #004ca7;
    border-radius: 9px;
    font-size: 14px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #004ca7;
  }
}
@fontFamily:"Microsoft YaHei";
.xpaas-table-class {
  border: 1px solid #004ca7;
  border-radius: 9px;
  > ::v-deep div.el-table__header-wrapper {
    > table.el-table__header {
      > thead {
        > tr.xpaas-header-row-class {
          padding: 0;
          height: 76px;
          background-color: #edf2f9;
          font-size: 16px;
          font-family: Microsoft YaHei;
          font-weight: bold;
          line-height: 20px;
          color: #004ca7;
          > th.xpaas-header-cell-class {
            font-weight: bold;
            border-right: 1px solid #c7d7eb;
            border-left: 0;
            border-bottom: 1px solid #c7d7eb;
            background-color: #edf2f9;
            > div.cell {
              font-size: 16px;
              font-weight: bold;
              font-family: @fontFamily;
              color: #004ca7;
            }
          }
        }
      }
    }
  }
  > ::v-deep div.el-table__body-wrapper {
    > table.el-table__body {
      > tbody {
        > tr.xpaas-row-class {
          > td.xpaas-header-cell-class {
            border-right: 1px solid #c7d7eb;
            border-left: 0;
            border-bottom: 1px solid #c7d7eb;
            background-color: #edf2f9;
            > div.cell {
              font-size: 16px;
              font-weight: bold;
              font-family: @fontFamily;
              color: #004ca7;
            }
          }
          > td.xpaas-cell-class {
            height: 76px;
            
            border-right: 1px solid #c7d7eb;
            border-left: 0;
            border-bottom: 1px solid #c7d7eb;
            > div.cell {
              font-weight: normal;
              font-family: @fontFamily;
              color: #004ca7;
            }
          }
        }
      }
    }
  }
}
</style>